listitemmanager: Update selections properly
authorBenjamin Otte <otte@redhat.com>
Mon, 8 Jun 2020 16:06:01 +0000 (18:06 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 8 Jun 2020 16:14:24 +0000 (18:14 +0200)
Replace a previous fix with a more correct one: Update the
selected state from the model instead of reusing the old state, the
model might have updated the selected state.

gtk/gtklistitemmanager.c

index e08592bca8ffdedd68bfd8594eab4552e2d8acc6..34c52e48bdeb73a0a4863e3a620d22a5d245b41e 100644 (file)
@@ -395,7 +395,6 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
 
   if (item == NULL || item->widget)
     item = gtk_rb_tree_insert_before (self->items, item);
-
   item->n_items += n_items;
   gtk_rb_tree_node_mark_dirty (item);
 
@@ -570,12 +569,6 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
     gtk_list_item_manager_release_list_item (self, NULL, widget);
 }
 
-static void
-gtk_list_item_manager_model_selection_changed_cb (GListModel         *model,
-                                                  guint               position,
-                                                  guint               n_items,
-                                                  GtkListItemManager *self);
-
 static void
 gtk_list_item_manager_model_items_changed_cb (GListModel         *model,
                                               guint               position,
@@ -742,8 +735,6 @@ gtk_list_item_manager_model_items_changed_cb (GListModel         *model,
 
   g_hash_table_unref (change);
 
-  gtk_list_item_manager_model_selection_changed_cb (model, position, added, self);
-
   gtk_widget_queue_resize (self->widget);
 }
 
@@ -988,7 +979,7 @@ gtk_list_item_manager_try_reacquire_list_item (GtkListItemManager *self,
       gtk_list_item_widget_update (list_item,
                                    position,
                                    gtk_list_item_widget_get_item (list_item),
-                                   gtk_list_item_widget_get_selected (list_item));
+                                   gtk_selection_model_is_selected (self->model, position));
       gtk_widget_insert_after (result, self->widget, prev_sibling);
       /* XXX: Should we let the listview do this? */
       gtk_widget_queue_resize (result);